package ch09.shili;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

//字符输出流
public class S06 {

    public static void main(String[] args) {
        //try-with-resources 自动释放资源
        try(Writer fw = new FileWriter("data/test3.txt")){
            fw.write("accp好吗");
            fw.flush();//刷新缓冲区
        } catch (IOException e) {
            e.printStackTrace();
        }
//        Writer fw = null;
//        try {
//            fw = new FileWriter("data/test3.txt");
//            fw.write("accp好");
//            fw.flush();//刷新缓冲区
//        }catch (IOException e) {
//            e.printStackTrace();
//        }finally {
//            if(fw != null) {
//                try {
//                    fw.close();
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }
//            }
//        }
    }
}
